﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;

public class BlogRepository
{
    /// <summary>
    /// 获取Top N
    /// </summary>
    /// <param name="count"></param>
    /// <returns></returns>
    public List<Post> GetTopList(int count)
    {
        PersonalSiteDataContext db = new PersonalSiteDataContext();

        IEnumerable<Post> posts = (from p in db.Posts
                                   orderby p.PubDate descending
                                   select p).Take(count);

        return posts.ToList<Post>();
    }

}
